class Solution:
    def row(self, matrix, r, n):
        for i in range(n):
            matrix[r][i] = 0

    def column(self, matrix, c, m):
        for i in range(m):
            matrix[i][c] = 0

    def setZeroes(self, matrix: list[list[int]]) -> None:
        m, n = len(matrix), len(matrix[0])
        temp = []
        for i in range(m):
            for j in range(n):
                if matrix[i][j] != 0:
                    continue
                temp.append((i, j))

        for it in temp:
            self.row(matrix, it[0], n)
            self.column(matrix, it[1], m)
